package com.weibo.survey.utils;

import java.security.MessageDigest;

public class DataUtils {

	public static String md5(String content) {
		StringBuilder builder = new StringBuilder();
		try {
			MessageDigest digest = MessageDigest.getInstance("md5");
			byte[] buffer = digest.digest(content.getBytes("UTF-8"));
			char[] chars = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
			for (byte b : buffer) {
				builder.append(chars[(b >> 4) & 0x0f]);
				builder.append(chars[b & 0x0f]);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return builder.toString();
	}
}
